// pages/user/user.js
import {ajax} from "../../utils/httpRequest";
import {GETUSERINFO, GETMYWORDS, GETWORDSINFO, USERBINDPHONENUMBER} from "../../utils/api";

Page({

  /**
   * 页面的初始数据
   */

  data: {
    showUserSetting: false,
    showRecharge: false,
    showTiXian: false,
    showBindPhone: false,
    showWordDetails: false,
    moneyItem: [50, 100, 200, 500, 1000, 2000],
    rechargeIndex: 0,
    check_pay: true,
    userWords: [
      {word: '我', number: 2, quality: 4},
      {word: '是', number: 2, quality: 3},
      {word: '小', number: 2, quality: 2},
      {word: '虎', number: 2, quality: 1}
    ],
    wordDetails:{
      word:'林',
      money:'10',
      color:4,
      standard_price:100,
      number:12,
      is_buy:'为购入'
    },
    word_puzzles:[{

    }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  userCenterClick() {
    this.setData({
      showUserSetting: true
    })
  },
  userSettingbgclick() {
    this.setData({
      showUserSetting: !this.data.showUserSetting
    })
  },
  userSettingListClick(e) {
    console.log(e.target.dataset.index)
    let index = e.target.dataset.index;
    if (index == 0) {
      this.setData({
        showBindPhone: true
      })
    }
    this.setData({
      showUserSetting: false
    })
  },
  chooseRecharge(e) {
    this.setData({
      rechargeIndex: e.target.dataset.index
    })
  },
  rechargeClick() {
    this.setData({
      showRecharge: true
    })
  },
  tixianclick() {
    this.setData({
      showTiXian: true
    })
  },
  cancleClick() {
    this.setData({
      showRecharge: false,
      showTiXian: false,
      showBindPhone: false,
      showWordDetails: false,
    })
  },
  wordsClick(){
    this.setData({
      showWordDetails:true
    })
  },
  toTradeline(){
    wx.navigateTo({
      url: '/pages/tradeLine/tradeLine',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})